﻿using System;

namespace ArmyManager.Items
{
	public class ItemAttribute
	{
		private static readonly Random Random = new Random();

		public enum AttributeTypes
		{
			CriticalRating,
			AttackPhysical,
			AttackMagical,
			DefensePhysical,
			DefenseMagical,
			Endurace,
			Health
		}

		public AttributeTypes AttributeType { get; private set; }
		public int Amount { get; private set; }

		public ItemAttribute(AttributeTypes attributeType, int amount)
		{
			AttributeType = attributeType;
			Amount = amount;
		}

		public ItemAttribute ReduceForFusion()
		{
			// New ammount will be anywhere between (25-50%) and (50-75%) of the current amount
			double lower = 25.0 + (25.0 * Random.NextDouble());
			double upper = 50.0 + (25.0 * Random.NextDouble());
			return new ItemAttribute(AttributeType, (int)(Amount * (Random.Next((int)lower, (int)upper)/100.0)));
		}

		public void AddAmount(int amount)
		{
			Amount += amount;
		}

		public ItemAttribute Clone()
		{
			return new ItemAttribute(AttributeType, Amount);
		}
	}
}